<script>
const map = new WeakMap()

function visitCount(user) {
  let count = map.get(user) || 0
  count+= 1
  map.set(user, count)
  return count
}
let user = {name: 'zhangsan'}
let user2 = {name: 'lisi'}
console.log(visitCount(user)) // 1
console.log(visitCount(user2)) // 1
console.log(visitCount(user)) // 2
user = null // 引用计数：0，是可回收的状态


</script>